-- card: 41128 from stack: in.5 -- bmap block id: 45332 -- flags: 0000 -- background id: 3858 -- name: SysEnvironment ----- HyperTalk script ----- on CloseCard put empty into cd fld "attribute list" set the scroll of cd fld "attribute list" to 0 pass CloseCard end CloseCard on HideObjects hide cd fld "attribute list" hide cd btn "try it!" end HideObjects on ShowObjects show cd fld "attribute list" show cd btn "try it!" end ShowObjects -- part 1 (button) -- low flags: 00 -- high flags: A002 -- rect: left=82 top=299 right=333 bottom=175 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 8192 -- line height: 16 -- part name: Try it! ----- HyperTalk script ----- on mouseUp global errGlobal put SysEnvironment("noDialog:errGlobal") into attribs if errGlobal ≠ empty then answer "Error:" && errGlobal put empty into errGlobal else put attribs into cd fld "attribute list" end if end mouseUp -- part 2 (field) -- low flags: 00 -- high flags: 0007 -- rect: left=11 top=117 right=288 bottom=249 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: attribute list -- part contents for background part 38 ----- text ----- 44/50 -- part contents for background part 20 ----- text ----- This XFCN returns the same information that the toolbox call SysEnvirons returns. The only difference is that we translate the information for you. This XFCN can not return the proper information for CPU's, keyboards or processors added since it was last updated. In this case it will say "unknown CPU xx" where xx is the number constant returned from the SysEnvirons call . Calling Syntax: SysEnvironment(«"noDialog:errGlobal"») -- part contents for background part 42 ----- text ----- unit sysEnv; { an XFCN which checks to see which type of Macintosh is running and what it's current } {environment is. returns a string of information separated by commas. uses SysEnviorns } {toolbox call, refer to IM V for more details } { values returned are: } { SysEnviorns version } { machine type (ie. Mac IIxx} { system version (ie. 9.0.1) } { processor (ie. 68040)} { has floating point (FPU) } { has color QuickDraw } { keyboard type } { AppleTalk Driver version } { system folder reference number } {} { brought to you by: Anup Murarka Eric Carlson } { ALINK: SKEPTIC ALINK: cyNic } { CIS: 76004,3356 } {} { We are part of the Support Tools Development Group, } { Apple Computer, Inc. } {} { please DO NOT contack Mac DTS for support of this code! } {} { please DO contact the authors for support of this code! } {} { Send comments, bug reports, requests to any of the above } { E-mail addresses or to:} {} { (one of us) } { Apple Computer, Inc. } { 900 E. Hamilton, Ave. } { Campbell, CA 95008 } { M/S 72-L } {} { Copyright: © 1989, 1990 by Apple Computer, Inc., all rights reserved. } {} { written by Eric Carlson } { AppleLink: cyNic } { modification history } { ----------------------------------------------------------------} { 11/12/90 ec corrected IIfx number (thought it was 12, is 11) reved to 1.3.1 } { 10/8/90 ec added code for LC, Classic, and IIsi. reved to 1.3 } { 6/1/90 ec recompiled with new library routined, added misc comments } { 3/20/90 ec added code for IIfx, changed version to 1.2 } { 9/19/89 ec added codes for IIci & portable, changed version to 1.1 } { 7/28/89 ec first written } {} interface uses HyperXCmd; procedure main (paramPtr: XCmdPtr); implementation procedure reportToUser (paramPtr: XCmdPtr; msgStr: str255); {} { report something back to the user. } { the last parameter (optional) to an external may contain } { "noDialog" or "noDialog:GlobalName". GlobalName is the name } { of a HyperTalk global variable into which error messages will be } { placed. we've decided to use this approach to avoid confusing } { an error message with a valid result being returned from an XFCN. } {} var tempStr: str255; begin {check the last param to see if the user requested that} { we suppress the error dialog } ZeroToPas(paramPtr, paramPtr^.params[paramPtr^.paramCount]^, tempStr); UprString(tempStr, true); if pos('NODIALOG', tempStr) = 0 then { no special error handling specified, throw up a dialog and return the error message } begin SendCardMessage(paramPtr, concat('answer "', msgStr, '"')); paramPtr^.returnValue := PasToZero(paramPtr, msgStr); end else if (pos(':', tempStr) > 0) then { requested global AND noDialog so we fill in the global and return empty } begin tempStr := copy(tempStr, pos(':', tempStr) + 1, length(tempStr)); { get the name of the HC global to fill } SetGlobal(paramPtr, tempStr, PasToZero(paramPtr, msgStr)); { and fill it } paramPtr^.returnValue := PasToZero(paramPtr, '');{ return empty } end else { requested noDialog only so we return the error condition as the result } paramPtr^.returnValue := PasToZero(paramPtr, msgStr); end;{ procedure } function AskedForHelp (paramPtr: XCmdPtr; syntaxMsg: Str255; copyrightMsg: Str255): boolean; {check to see if the user sent a '?' or a '!' as } { the only parameter. if so we will respond with } { the calling syntax or the copyright/version info } { for this external } {} var firstStr: str255; begin askedForHelp := false; if paramPtr^.paramCount = 1 then begin ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr); { what is the first param? } if firstStr = '?' then begin reportToUser(paramPtr, syntaxMsg); askedForHelp := true end{ asked for help } else if firstStr = '!' then begin reportToUser(paramPtr, copyRightMsg); askedForHelp := true end;{ asked for copyright info } end;{ one parameter passed } end;{ function } function NumberToHex (paramPtr: XCmdPtr; num: LONGINT; nDigits: INTEGER): Str255; { why, oh why did dan write this one as a procedure??? } var tempStr: str255; begin NumToHex(paramPtr, num, nDigits, tempStr); NumberToHex := tempStr; end; function NumberToString (paramPtr: XCmdPtr; num: LONGINT): Str255; { use the toolbox call rather than HC's } var tempStr: str255; begin NumToString(num, tempStr); NumberToString := tempStr; end; procedure sysEnv (paramPtr: XCmdPtr); var theSysRec: SysEnvRec; err, tempInt: Integer; tempStr, theResult: Str255; begin if askedForHelp(paramPtr, 'sysEnvironment([“noDialog”:errorGlobal])', ' v1.3.1 © 1989, 1990 Apple Computer, Inc., by Eric Carlson') then exit(sysEnv);{ exit just asking for help } err := SysEnvirons(1, theSysRec);{ make our call } if err <> 0 then begin ReportToUser(paramPtr, 'Problem calling SysEnvironment.'); Exit(sysEnv); end; case theSysRec.machineType of{ what machine are we on? } -1: tempstr := 'Macintosh with 64K ROM,'; -2: tempstr := 'Macintosh XL,'; 0: tempstr := 'unknown Macintosh,'; 1: tempstr := 'Macintosh 512KE,'; 2: tempstr := 'Macintosh Plus,'; 3: tempstr := 'Macintosh SE,'; 4: tempstr := 'Macintosh II,'; 5: tempstr := 'Macintosh IIx,'; 6: tempstr := 'Macintosh IIcx,'; 7: tempstr := 'Macintosh SE/30,'; 8: tempstr := 'Macintosh Portable,'; 9: tempstr := 'Macintosh IIci,'; 11: tempstr := 'Macintosh IIfx,'; 15: tempstr := 'Macintosh Classic,'; 16: tempstr := 'Macintosh IIci,'; 17: tempstr := 'Macintosh LC,'; otherwise tempstr := concat('unknown machine #', NumberToString(paramPtr, theSysRec.machineType), ', '); end; theResult := tempstr; tempStr := NumberToHex(paramPtr, theSysRec.systemVersion, 3);{ now the system version } for tempInt := 1 to 3 do theResult := concat(theResult, tempstr[tempInt], '.'); theResult[length(theResult)] := ',';{ kill trailing period } case theSysRec.processor of { and the processor } 0: tempstr := 'CPU Unknown,'; 1: tempstr := 'Motorola 68000,'; 2: tempstr := 'Motorola 68010,'; 3: tempstr := 'Motorola 68020,'; 4: tempstr := 'Motorola 68030,'; 5: tempstr := 'Motorola 68030,'; 6: tempstr := 'Motorola 68040,'; otherwise tempstr := concat('unknown CPU #', NumberToString(paramPtr, theSysRec.processor), ', '); end; theResult := concat(theResult, tempstr); if theSysRec.hasFPU then { do we have a coprocessor? } tempstr := 'FPU,' else tempstr := 'no FPU,'; theResult := concat(theResult, tempstr); if theSysRec.hasColorQD then { do we have color QD? } tempstr := 'Color Quick Draw,' else tempstr := 'No Color Quick Draw,'; theResult := concat(theResult, tempstr); case theSysRec.keyBoardType of { what keyboard was this typed on? } 0: tempstr := 'Macintosh Plus keyboard with keypad,'; 1: tempstr := 'Macintosh keyboard,'; 2: tempstr := 'Macintosh keyboard and keypad,'; 3: tempstr := 'Macintosh Plus keyboard,'; 4: tempstr := 'Apple Extended keyboard,'; 5: tempstr := 'Standard ADB keyboard,'; 6: tempstr := 'Portable Keyboard,'; 7: tempstr := 'Portable Keyboard (ISO),'; 8: tempstr := 'Apple Standard Keyboard (ISO),'; 9: tempstr := 'Apple Extended Keyboard (ISO),'; otherwise tempstr := concat('UnknownKbd #', NumberToString(paramPtr, theSysRec.keyBoardType), ', '); end; theResult := concat(theResult, tempstr); tempstr := NumberToString(paramPtr, theSysRec.atDrvrVersNum); { appletalk present? } if tempStr = '0' then theResult := concat(theResult, 'AppleTalk not connected,') else theResult := concat(theResult, 'AppleTalk version (', tempstr, ')', ','); tempstr := NumberToString(paramPtr, theSysRec.sysVRefNum); { system folder wd ref num } theResult := concat(theResult, 'System Folder wdRefNum (', tempstr, ')'); paramPtr^.returnValue := PasToZero(paramPtr, theResult); { all done, send in the results } end; procedure main; begin sysEnv(paramPtr); end; end.